﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using HF.Architecture.Data;
using HF.User.Data;
using HF.Framework.Web;

public partial class BasePages_AccreditPage_Userfrm : System.Web.UI.Page
{
    string keyType = "";
    string keyValue = "";
    protected void Page_Load(object sender, EventArgs e)
    {
        if (this.Request["keyType"] != null && this.Request["keyValue"] != null)
        {
            keyType = this.Request["keyType"].ToString();
            keyValue = this.Request["keyValue"].ToString();
            initData(keyType,keyValue);
        }

        
    }
    public void BuildNoRecords(GridView gridView, DataTable dt)
    {
        try
        {
            if (dt.Rows.Count == 0)
            {
                dt.Rows.Add(dt.NewRow());
                gridView.DataSource = dt;
                gridView.DataBind();
                int columnCount = gridView.Rows[0].Cells.Count;
                gridView.Rows[0].Cells.Clear();
                gridView.Rows[0].Cells.Add(new TableCell());
                gridView.Rows[0].Cells[0].ColumnSpan = columnCount;
                gridView.Rows[0].Cells[0].Text = "没有数据.";
            }
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }
    private void initData(string keyType,string keyValue)
    {
        DataTable dt = ArchitectureData.GetInstance().GetUsers(keyValue);
        gvUsers.DataSource = dt;
        gvUsers.DataBind();
        BuildNoRecords(gvUsers,dt);

    }
    protected void search_Click(object sender, EventArgs e)
    {
        if (tbxUserName.Text.Length == 0)
        {
            WorkDialog.ShowMessage(this,"请输入帐号或者用户名!");
            return;

        }

        DataTable dtSearch = null;
        dtSearch = UserData.GetInstance().GetUserTableLikeName(tbxUserName.Text);
        gvUsers.DataSource = dtSearch;
        gvUsers.DataBind();
        BuildNoRecords(gvUsers, dtSearch);
    }
    protected void CheckBox1_CheckedChanged(object sender, EventArgs e)
    {
        
    }
}
